<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <input type="text" id="username">
        <input type="text" id="password">
        <button id="btn">登录</button>
    </div>
    <script>
        let name = document.getElementById('username');
        let password = document.getElementById('password');
        let btn = document.getElementById('btn');
        btn.addEventListener('click', () => {
            // 获取输入框的值
            let usernameValue = name.value;
            let passwordValue = password.value;
            // 构建包含输入值的 URL
            let url = `http://localhost:3000/login?username=${usernameValue}&password=${passwordValue}`;
            // 发送请求
            fetch(url, {
                method: 'GET'
            })
                .then(response => response.text())
                .then(data => console.log(data))
                .catch(error => console.error('请求出错:', error));
        });
    </script>
</body>

</html>